import { BasicColumn } from '/@/components/Table/src/types/table';
import { FormSchema } from '/@/components/Form';
import { useI18n } from '/@/hooks/web/useI18n';
const { t } = useI18n();

// 项目模板表格数据
export function dataColumns(): BasicColumn[] {
  return [
    {
      title: t('routes.project.projectTemplate.templateName'),
      dataIndex: 'templateName',
      fixed: 'left',
      width: 300,
    },
    {
      title: t('routes.project.projectTemplate.projectType'),
      dataIndex: 'proorg',
      width: 100,
      slots: { customRender: 'proorg' },
    },
    {
      title: t('routes.project.projectTemplate.templateDesc'),
      dataIndex: 'templateDescription',
      width: 150,
      slots: { customRender: 'templateDescription' },
    },
  ];
}

// 项目模板搜索数据
export function dataSearchFormSchema(): FormSchema[] {
  return [
    {
      field: `templateName`,
      label: t('routes.project.projectTemplate.templateName'),
      component: 'Input',
      colProps: {
        xl: 8,
        xxl: 8,
      },
      componentProps: {
        placeholder: t('routes.project.projectTemplate.templateNamePlaceholder'),
      },
    },
    {
      field: `proorg`,
      label: t('routes.project.projectTemplate.projectType'),
      component: 'Select',
      colProps: {
        xl: 8,
        xxl: 8,
      },
      componentProps: {
        placeholder: t('routes.project.projectTemplate.templateDescPlaceholder'),
        options: [],
      },
    },
  ];
}

// 项目模板表单数据
export function dataFormSchema(): FormSchema[] {
  return [
    {
      field: `templateName`,
      label: t('routes.project.projectTemplate.templateName'),
      component: 'Input',
      required: true,
      defaultValue: '',
      componentProps: {
        placeholder: t('routes.project.projectTemplate.templateNamePlaceholder'),
      },
    },
    {
      field: `proorg`,
      label: t('routes.project.projectTemplate.projectType'),
      component: 'Select',
      defaultValue: '',
      componentProps: {
        placeholder: t('routes.project.projectTemplate.projectTypePlaceholder'),
        options: [],
      },
    },
    {
      field: `templateDescription`,
      label: t('routes.project.projectTemplate.templateDesc'),
      component: 'Input',
      defaultValue: '',
      componentProps: {
        placeholder: t('routes.project.projectTemplate.templateDescPlaceholder'),
      },
    },
  ];
}

// 模板详情表格
export function tempDetailColumns(): BasicColumn[] {
  return [
    {
      title: t('routes.project.projectTemplate.taskName'),
      dataIndex: 'label',
      width: 300,
      fixed: 'left',
    },
    {
      title: t('routes.project.projectTemplate.taskCode'),
      dataIndex: 'taskNumber',
      width: 100,
    },
    {
      title: t('routes.project.projectTemplate.duration'),
      dataIndex: 'workDays',
      width: 100,
    },
    {
      title: t('routes.project.projectTemplate.executor'),
      dataIndex: 'executor',
      width: 100,
      slots: { customRender: 'executor' },
    },
    {
      title: t('routes.project.projectTemplate.autoEffective'),
      dataIndex: 'approve',
      width: 300,
      slots: { customRender: 'approve' },
    },
    {
      title: t('routes.project.projectTemplate.milestone'),
      dataIndex: 'milestone',
      width: 100,
      slots: { customRender: 'milestone' },
    },
  ];
}

// 模板详情搜索
export function tempDetailSearch(): FormSchema[] {
  return [
    {
      field: `label`,
      label: t('routes.project.projectTemplate.taskName'),
      component: 'Input',
      colProps: {
        xl: 8,
        xxl: 8,
      },
      componentProps: {
        placeholder: t('routes.project.projectTemplate.taskNamePlaceholder'),
      },
    },
    {
      field: `executor`,
      label: t('routes.project.projectTemplate.executor'),
      component: 'Select',
      colProps: {
        xl: 8,
        xxl: 8,
      },
      componentProps: {
        placeholder: t('routes.project.projectTemplate.executorPlaceholder'),
        options: [],
      },
    },
  ];
}

// 模板详情新增，修改
export function temDetailForm(): FormSchema[] {
  return [
    {
      field: `label`,
      label: t('routes.project.projectTemplate.taskName'),
      component: 'Input',
      defaultValue: '',
      componentProps: {
        placeholder: t('routes.project.projectTemplate.taskNamePlaceholder'),
      },
      colProps: {
        xl: 12,
        xxl: 12,
      },
    },
    {
      field: `taskNumber`,
      label: t('routes.project.projectTemplate.taskCode'),
      component: 'Input',
      defaultValue: '',
      componentProps: {
        placeholder: t('routes.project.projectTemplate.taskCodePlaceholder'),
      },
      colProps: {
        xl: 12,
        xxl: 12,
      },
    },
    {
      field: `workDays`,
      label: t('routes.project.projectTemplate.duration'),
      component: 'InputNumber',
      defaultValue: 0,
      componentProps: {
        placeholder: t('routes.project.projectTemplate.durationPlaceholder'),
      },
      colProps: {
        xl: 12,
        xxl: 12,
      },
    },
    {
      field: `executor`,
      label: t('routes.project.projectTemplate.executor'),
      component: 'Select',
      defaultValue: '',
      componentProps: {
        placeholder: t('routes.project.projectTemplate.executorPlaceholder'),
      },
      colProps: {
        xl: 12,
        xxl: 12,
      },
    },
    {
      field: `approve`,
      label: t('routes.project.projectTemplate.autoEffective'),
      component: 'Switch',
      defaultValue: false,
      colProps: {
        xl: 12,
        xxl: 12,
      },
    },
    {
      field: `milestone`,
      label: t('routes.project.projectTemplate.milestone'),
      component: 'Switch',
      defaultValue: false,
      colProps: {
        xl: 12,
        xxl: 12,
      },
    },
    {
      field: `predecessor`,
      label: t('routes.project.projectTemplate.preTask'),
      component: 'Select',
      defaultValue: '',
      componentProps: {
        placeholder: t('routes.project.projectTemplate.preTaskPlaceholder'),
      },
    },
    {
      label: t('routes.project.projectTemplate.customProperty'),
      field: 'taskCustomizeList',
      slot: 'taskCustomize',
      defaultValue: [],
      component: 'Input',
    },
  ];
}
